import elu.base.model as model
from sqlalchemy.sql import text


class ProjectModel:
    def __init__(self):
        self.engine = model.engine
        self.meta = model.meta

    def c(self):
        pass

    def u(self):
        pass

    def r(self):
        raw = """
            select 
            data.*, 
            (select su_app.name from supp_application as su_app where su_app.id=data.application_id) application_waver,
            (select su_pro.name from supp_personnel as su_pro where su_pro.id=data.product_id) product_waver,
            (select su_int.name from supp_personnel as su_int where su_int.id=data.interact_de_id) interact_de_waver,
            (select su_gra.name from supp_personnel as su_gra where su_gra.id=data.graphic_de_id) graphic_de_waver,
            (select su_fro.name from supp_personnel as su_fro where su_fro.id=data.frontend_de_id) frontend_de_waver
            from data_project as data where data.na = 1"""
            
        result = self.engine.execute(raw)
        return [dict(row) for row in result]

    def d(self):
        pass
